package com.woniuxy.sales.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.woniuxy.sales.model.entity.China;

import com.woniuxy.sales.service.ChinaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 地址控制器
 */
@RestController
@RequestMapping("/china")
@Api(tags = "地址接口")
public class ChinaController {

    @Autowired
    private ChinaService chinaService;

    @GetMapping("/getAllProvince")
    @ApiOperation("获取所有省份")
    public ResponseEntity<List<China>> getAllProvince() {
        List<China> list = chinaService.list(
                Wrappers.lambdaQuery(China.class)
                        .eq(China::getLevel, 1)
                        .orderByAsc(China::getId)
        );
        return ResponseEntity.ok(list);
    }
}